//
//  ExampleNet.swift
//  testZD
//
//  Created by 湛亚磊 on 2020/9/21.
//  Copyright © 2020 湛亚磊. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift
///-------------------- 配置 url 和 网络层的分类 ----------------------
/// baseurl
//let exampleBaseUrl = "*******"
/////url
//let exampleGetHomeDataURL = "api/front/exclude/appHome"
//let exampleGetHomeDataURL2 = "api/front/exclude/appHome"
/////填写baseurl
//extension LZBaseApi {
//    var baseURL: URL {
//        URL(string: exampleBaseUrl)!
//    }
//}
///// 配置网络层分类
//class LZRequestManager: NSObject {
//    static let exampleHomeApi = LZNetWorking<ExampleHomeApi>()
//}





///----------------------- 网络层的分类的具体实现 ------------------------
//import Moya
//
//enum ExampleHomeApi:LZBaseApi{
//    ///获取首页数据
//    case getExampleHomeInfo
//    case getExampleHomeInfo2(_ params:[String:Any])
//}
//
//extension ExampleHomeApi{
//    var path: String{
//        switch self {
//        case .getExampleHomeInfo:
//            return exampleGetHomeDataURL
//        case .getExampleHomeInfo2(_):
//            return exampleGetHomeDataURL2
//        }
//    }
//    var method: Moya.Method{
//        switch self {
//        default:
//            return .post
//        }
//    }
//    var cacheType: LZApiCacheType{
//        return .none
//    }
//    var task: Task{
//        switch self {
//            /// json的传参
//        case .getExampleHomeInfo:
//            return .requestParameters(parameters: ["":""], encoding: JSONEncoding.default)
//        case .getExampleHomeInfo2(let params):
//            /// 普通的传参
//            return .requestParameters(parameters: params, encoding: URLEncoding.default)
//        }
//    }
//    var headers: [String : String]?{
//        let headers = ["Content-type":"application/x-www-form-urlencoded"]
////        if UserManager.sharedInstance.isLogin(){
////                headers["Authorization"] = UserManager.sharedInstance.getUserToken()
////                print("头部的token---->>>>\(UserManager.sharedInstance.getUserToken())")
////        }
//        return headers
//    }
//    var sampleData: Data{
//        return Data()
//    }
//}



/// 使用示例
///网络层调用示例
//private func exampleAction(with parms:AnyObject) -> Observable<AnyObject> {
//    var params:Dictionary<String,Any> = Dictionary<String,String>()
//    params["example1"]=1
//    params["example2"]=2
//    let response:Observable<AnyObject> = LZRequestManager.exampleHomeApi.getResponse(target: .getExampleHomeInfo2(params), with: .nomal, withDebug: true).map { (responseData) -> AnyObject in
//        return responseData.0 ?? 1 as AnyObject
//    }
//    return response
//}
